package top.wilsonlv.jaguar.security.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import top.wilsonlv.jaguar.commons.web.WebConstant;

/**
 * @author lvws
 * @since 2021/7/5
 */
@Order(200)
@Configuration
@EnableWebSecurity
public class WebIgnoreSecurityConfigurer extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(WebSecurity web) {
        WebSecurity.IgnoredRequestConfigurer ignoring = web.ignoring();
        for (String staticResourceExtension : WebConstant.STATIC_RESOURCE_EXTENSIONS) {
            ignoring.antMatchers(WebConstant.MATCH_ALL + staticResourceExtension);
        }
        ignoring.antMatchers("/captcha/**", "/error");
        ignoring.antMatchers("/swagger-resources", "/swagger-resources/**", "/v2/api-docs");
        ignoring.antMatchers("/druid/**");
    }

}
